/* ******************************************************** menu *********** */
var currentMenu = "";

function hiddenDetail() {
	top.document.getElementById("list").style.display = "block";
	// loading processing ~~~~~~~~~~~~~
	top.document.getElementById("detFrame").src = "";
	top.document.getElementById("detail").style.display = "none";

}

function openSub(sub) {
	if (currentMenu == "") {
		document.getElementById("subMenu").style.display = "block";
		document.getElementById(sub).style.display = "block";
		currentMenu = sub;
	} else if (currentMenu == sub) {
		document.getElementById("subMenu").style.display = "none";
		document.getElementById(sub).style.display = "none";
		currentMenu = "";
	} else {
		document.getElementById(currentMenu).style.display = "none";
		document.getElementById(sub).style.display = "block";
		currentMenu = sub;
	}
}
/* 1024 * 768 */
/* 1014 * 739 */
/* 1014 * 711 */

function openSize(url) {
	window
			.open(url, "myD2sign",
					"width=1014px, height=711px, top=0px, left=0px, menubar=no, status=no");
}

function clearIdPw() {
	document.getElementById("logInUserId").value = "";
	document.getElementById("logInUserPw").value = "";
}

function closeSpan() {
	document.getElementById("subMenu").style.display = "none";
	document.getElementById("closeSpanMenu").style.display = "none";
}

/* ******************************************************** login *********** */

function fn_pw_focus(){
	document.getElementById("userPw").value = "";
	document.getElementById("userPw").type = "password";	
}

function enterLogIn() {
	if (event.keyCode == 13) {
		logIn();
	}
}

function showLogInIdBox() {
	document.getElementById("userId").style.display = "none";
	document.getElementById("userIdFocus").value = "";
	document.getElementById("userIdFocus").style.display = "block";
	document.getElementById("userIdFocus").focus();
}

function logIn() {
	/* ************************************ saving page infomation */
	document.getElementById("pPage").value = document.location.href;

	if (document.getElementById("logInUserId").value == "") {
		alert("ID�� ������ϴ�.");
	} else if (document.getElementById("logInUserPw").value == "") {
		alert("��й�ȣ�� ������ϴ�.");
	} else {
		document.logInUser.action = "./header/loginProcess.jsp";
		document.logInUser.submit();
	}
}

function logOut() {
	document.logInUser.action = "./header/logOutProcess.jsp";
	document.logInUser.submit();
}

function joinUs() {
	top.location.href = "./joinMember.jsp";
}

function findMember() {
	var url = "./header/findForgottenID.jsp";
	var pop_name = 'pop_findMember';
	var pop_type = 'left=' + (event.screenX - 240);
	pop_type += ',top=' + event.screenY;
	pop_type += ',toolbar=no';
	pop_type += ',location=no';
	pop_type += ',directories=no';
	pop_type += ',status=no';
	pop_type += ',menubar=no';
	pop_type += ',scrollbars=no';
	pop_type += ',resizable=yes';
	pop_type += ',copyhistory=yes';
	pop_type += ',width=400';
	pop_type += ',height=240';
	window.open(url, pop_name, pop_type)
}

function seekId() {
}

function findId() {
	var userName = document.getElementById("searchName").value;
	var searchSSN1 = document.getElementById("searchSSN1").value;
	var searchSSN2 = document.getElementById("searchSSN2").value;
	if (userName == "") {
		alert("�̸��� �Է����ּ���.");
		document.getElementById("searchName").focus();
	} else if (searchSSN1 == "" || searchSSN2 == "") {
		alert("�ֹι�ȣ�� �Է����ּ���.");
	} else {
		createRequest();
		var url = "findForgetId.jsp";
		url = url + "?searchName=" + userName;
		url = url + "&searchPNo1=" + searchSSN1;
		url = url + "&searchPNo2=" + searchSSN2;
		url += "&dummy =" + new Date().getTime();
		request.open("GET", url, true);
		request.onreadystatechange = updateFindIdPage;
		request.send(null);

		document.getElementById("showId").style.display = 'block';
	}

}

function updateFindIdPage() {
	if (request.readyState == 4) {
		var countId = request.responseText;
		var resultId = document.getElementById("searchResultId");
		replaceText(resultId, countId);
	}
}

function findPw() {
	var userName = document.getElementById("searchName").value;
	var searchSSN1 = document.getElementById("searchSSN1").value;
	var searchSSN2 = document.getElementById("searchSSN2").value;
	if (userName == "") {
		alert("�̸��� �Է����ּ���.");
		document.getElementById("searchName").focus();
	} else if (searchSSN1 == "" || searchSSN2 == "") {
		alert("�ֹι�ȣ�� �Է����ּ���.");
	} else {
		createRequest();
		var url = "findForgetPw.jsp";
		url = url + "?searchName=" + userName;
		url = url + "&searchPNo1=" + searchSSN1;
		url = url + "&searchPNo2=" + searchSSN2;
		url += "&dummy =" + new Date().getTime();
		request.open("GET", url, true);
		request.onreadystatechange = updateFindPwPage;
		request.send(null);

		document.getElementById("showPw").style.display = 'block';
	}

}

function updateFindPwPage() {
	if (request.readyState == 4) {
		var countId = request.responseText;

		if (countId.substr(0, 1) == "��") {
			countId = changePw(countId);
		}

		var resultPw = document.getElementById("searchResultPw");
		replaceText(resultPw, countId);
	}
}

function changePw(pw) {
	var len = pw.length;
	var pos = 7;
	var head;
	var tail;

	while (pos + 1 != len - 5) {
		head = pw.substr(0, pos)
		tail = pw.substr(pos + 1, len - pos);
		pw = head + "*" + tail;
		pos++;
	}
	return pw;
}

function showUserInfo() {
	top.location.href = "./showUserInfo.jsp";
}
